﻿<local:FrictionTextBox x:Class="Daytimer.Controls.Friction.FrictionTextBoxControl"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:local="clr-namespace:Daytimer.Controls.Friction" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
	<local:FrictionTextBox.Style>
		<Style TargetType="TextBox">
			<Setter Property="BorderThickness" Value="1" />
			<Setter Property="Background" Value="{DynamicResource White}" />
			<Setter Property="BorderBrush" Value="#FFABADB3" />
			<Setter Property="SelectionBrush" Value="#FF909090" />
			<Setter Property="SelectionOpacity" Value="0.5" />
			<Setter Property="Foreground" Value="{DynamicResource Black}" />
			<Setter Property="ContextMenu">
				<Setter.Value>
					<ContextMenu>
						<MenuItem Header="Cu_t" Command="ApplicationCommands.Cut" InputGestureText="Ctrl+X">
							<MenuItem.Icon>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/cut.png" />
							</MenuItem.Icon>
						</MenuItem>
						<MenuItem Header="_Copy" Command="ApplicationCommands.Copy" InputGestureText="Ctrl+C">
							<MenuItem.Icon>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/copy.png" />
							</MenuItem.Icon>
						</MenuItem>
						<MenuItem Header="_Paste" Command="ApplicationCommands.Paste" InputGestureText="Ctrl+V">
							<MenuItem.Icon>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/paste_sml.png" />
							</MenuItem.Icon>
						</MenuItem>
						<Separator />
						<MenuItem Header="_Undo" Command="ApplicationCommands.Undo" InputGestureText="Ctrl+Z">
							<MenuItem.Icon>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/undo.png" />
							</MenuItem.Icon>
						</MenuItem>
						<MenuItem Header="_Redo" Command="ApplicationCommands.Redo" InputGestureText="Ctrl+Y">
							<MenuItem.Icon>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/redo.png" />
							</MenuItem.Icon>
						</MenuItem>
					</ContextMenu>
				</Setter.Value>
			</Setter>
			<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TextBoxBase}">
						<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}"
								BorderThickness="{TemplateBinding BorderThickness}"
								Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>
								<ScrollViewer x:Name="PART_ContentHost"
										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
									<ScrollViewer.Template>
										<ControlTemplate TargetType="{x:Type ScrollViewer}">
											<ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
													CanContentScroll="{TemplateBinding CanContentScroll}"
													CanHorizontallyScroll="False" CanVerticallyScroll="False"
													ContentTemplate="{TemplateBinding ContentTemplate}"
													Content="{TemplateBinding Content}"
													Margin="{TemplateBinding Padding}" />
										</ControlTemplate>
									</ScrollViewer.Template>
								</ScrollViewer>
								<ScrollBar x:Name="scrollBar" Grid.Column="1" Scroll="scrollBar_Scroll"
										Visibility="Collapsed" />
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsEnabled" Value="False">
								<Setter Property="Opacity" TargetName="border" Value="0.56" />
							</Trigger>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA" />
							</Trigger>
							<Trigger Property="IsKeyboardFocused" Value="True">
								<Setter Property="BorderBrush" TargetName="border" Value="#FF569DE5" />
							</Trigger>
							<Trigger Property="Validation.HasError" Value="True">
								<Setter Property="BorderBrush" TargetName="border" Value="#FFFF0000" />
								<Setter Property="ToolTip"
										Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</local:FrictionTextBox.Style>
</local:FrictionTextBox>